# -*- coding: utf-8 -*-
# @File    : db.py
# @Date    : 2021-11-16
# @Author  : Richard

import os
import time
import dmPython

class DB(object):
    def __init__(self, sql, ip, user, pwd,port):
        self.sql = sql
        self.ip = ip
        self.user = user
        self.pwd = pwd
        self.port = port

    def run_sql(self):
        try:
            conn = dmPython.connect(user=self.user, password=self.pwd, server=self.ip, port=self.port)
            cursor = conn.cursor()
            cursor.execute(self.sql)
            conn.commit()
            cursor.close()
            conn.close()
        except Exception as Err:
            # raise
            print("Execute sql statement error is:{0}".format(Err))
